package LeetCode2;

import java.util.Arrays;

public class LC_189 {
    public void rotate(int[] nums, int k) {
        int n = 0;
        while(n < k){
            int temp = nums[nums.length-1];
            for(int i = nums.length-1; i > 0; i--){
                nums[i] = nums[i-1];
            }
            nums[0] = temp;
            n++;
        }
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5,6,7};
        int[] temp = new int[nums.length];
        int k = 3;
        System.arraycopy(nums,nums.length-k,temp,0,k);
        System.arraycopy(nums,0,temp,k,nums.length-k);
        nums = temp;
        System.out.println(Arrays.toString(nums));
        System.out.println(Arrays.toString(temp));
//        nums = temp;
//        System.out.println(nums[0]);
//        nums = Arrays.copyOf(temp,temp.length);
//        System.out.println(nums[1]);
    }
    public static void main1(String[] args) {
        LC_189 l = new LC_189();
        int[] nums = {1,2,3,4,5,6,7};
        l.rotate(nums,3);
        System.out.println(Arrays.toString(nums));
    }
}
